var store = Ext.create('AM.store.MyJobStore');
     store.load({
     callback: function(records, operation, success) {
	 if(store.getCount()>0){   
		Ext.namespace("Ext.ux");
		Ext.ux.ToastWindowMgr = {positions: []};
		Ext.ux.ToastWindow = Ext.extend(Ext.Window, {
			initComponent: function(){
			Ext.apply(this, {iconCls: this.iconCls || 'information',
							 width: 250,
							 height: 150,
							 autoScroll: true,
							 autoDestroy: true,
							 plain: false,
							 shadow:false
				});
				this.task = new Ext.util.DelayedTask(this.hide, this);
				Ext.ux.ToastWindow.superclass.initComponent.call(this);
			},
			setMessage: function(msg){
				this.body.update(msg);
			},
			setTitle: function(title, iconCls){
				Ext.ux.ToastWindow.superclass.setTitle.call(this, title, iconCls||this.iconCls);
			},
			onRender:function(ct, position) {
				Ext.ux.ToastWindow.superclass.onRender.call(this, ct, position);
			},
			onDestroy: function(){
				Ext.ux.ToastWindowMgr.positions.remove(this.pos);
				Ext.ux.ToastWindow.superclass.onDestroy.call(this);
			},
			afterShow: function(){
			  Ext.ux.ToastWindow.superclass.afterShow.call(this);
			  this.on('move', function(){
			    Ext.ux.ToastWindowMgr.positions.remove(this.pos);
			    this.task.cancel();
			  }, this);
			  this.task.delay(7000);
			},
			animShow: function(){
				 this.pos = 0;
				 while(Ext.ux.ToastWindowMgr.positions.indexOf(this.pos)>-1)
				 this.pos++;
				 Ext.ux.ToastWindowMgr.positions.push(this.pos);
				 this.setSize(250,150);
				 this.el.alignTo( document, "br-br", [ -20, -20-((this.getSize().height+10)*this.pos) ]);
				 this.el.slideIn('b', {
				   		duration: 2,
				   		callback: this.afterShow,
				   		scope: this
				   });
			},
			animHide: function(){
				Ext.ux.ToastWindowMgr.positions.remove(this.pos);
				this.el.ghost("b", {
					duration: 2,
					remove: true,
					scope: this,
					callback: this.destroy
				});
			}
		});
Ext.onReady(function(){
	
    
			var screenHeight =window.screen.height; //屏幕分辨率的高
			var screenWidth =window.screen.width; //屏幕分辨率的宽 
			 var width=window.screen.availWidth;
	 		 var height=window.screen.availHeight;
					new Ext.ux.ToastWindow({
						title: '提示窗口',
						html: '您有：（'+store.getCount()+'）个待办任务需要完成',
						iconCls: 'error',
//						x:width-265,
//						y:height-265
						x:screenWidth-265,
						y:screenHeight-265
						}).show(document);
					})
		      }       
	 }
 })
 
function getSesssionName (){ 
    var name;
 	Ext.Ajax.request({
				url : 'employees_personName',
				async : false,
				success : function(response) {
					var text =Ext.JSON.decode(response.responseText);
					name=text.name;
				},
				failure : function() {
					
				}
});		
		return name;
} 
 
Ext.define('AM.view.MainLayout', {
		      extend: 'Ext.panel.Panel',
		      alias : 'widget.mainlayout',
			    layout: 'border',
			    items: [{
			    	border: false,
			        region:'north',     // position for region
			        xtype: 'panel',
			        height: 72,
//			        split: true,         // enable resizing
//			        html : '<img width="100%" height="100%" src="image/youyititle.gif"></img>',
				    html: '<div style="height:70px;width:100%;">' +
							   				'<div style=" margin:46px 10px 20px 1100px; width:200px; height:30px;  position:absolute; z-index:2222">' +
						   							'当前用户：'+getSesssionName()+'，<a href="#"; onclick="logout()";>退出</a>' +
						   					'</div>' +
						   					
					   						'<div >' +
					   							'<img width="100%" height="100%" border="0" src=image/new5.jpg />' +
						   					'</div>' +
							 '</div>',
			        margins: '0 0 10 0'
			    },{
			        region:'south',     // position for region
//			        xtype: 'panel',
			        border: false,
			        height: 30,
			        split: true,         // enable resizing
			        margins: '0 5 5 5',
			        html : '<div style="line-height:29px;font-size:12px;text-align:center;">版权所有 c 北京西马远东医疗投资有限公司</div>'
			    },{
			        title: '菜单导航',
			        region:'west',
			        xtype: 'panel',
			        margins: '5 0 0 5',
			        width: 200,
			        collapsible: true,   
			        id: 'west-region-container',
//			        layout: 'accordion',
			        layout: 'fit',
			        split: true,   
			        items: [{
				        xtype: "menuView",
				        id:'west-container'
			        }]
			    },{
			        region: 'center',     // center region is required, no width/height specified
			        xtype: 'tabpanel',
			        id:'center-region-container',
			        margins: '5 5 0 0',
			        activeTab : 0,
			        items: [{
			        	 title: '主页',
			        	 xtype: "privateJobView",
						 id:'center-container'
				  }],
				  listeners: {
						tabchange: function (  tabPanel, newCard, oldCard, eOpts){
							  	 	var n=newCard.getId();
							  	 	var m=n.length;
							  	 	var treeid=n.substring(4,m);
							  	 	var treePanel= Ext.getCmp("west-container"); 
								    var record =treePanel.getStore().getNodeById(treeid);
								    treePanel.getSelectionModel().select(record)
					  	 	
					  	 }
				  }
			    }]

});
 function logout(){
  		Ext.MessageBox.confirm("提示", "确认要退出系统 ？", function(btn) {
							if (btn == 'yes') {			
								  document.location='login.html';
								}else{
										
								}
					  	})
 
  }    
   
  
      